package com.szml.logging.config;

import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @Author limin
 * @date 2025-06-21 19:44
 * @description
 */
public class AsyncConfig implements AsyncConfigurer {
    @Override
    @Bean(name = "rocketMQTaskExecutor")
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10); // 核心线程数
        executor.setMaxPoolSize(20);  // 最大线程数
        executor.setQueueCapacity(1000); // 队列容量
        executor.setThreadNamePrefix("RocketMQ-Async-");
        executor.initialize();
        return executor;
    }
}
